import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.read_csv("NFLX.csv")
df.head()
| Date | Open | High | Low | Close | Adj Close | Volume | |
|---|---|---|---|---|---|---|---|
| 0 | 2002-05-23 | 1.156429 | 1.242857 | 1.145714 | 1.196429 | 1.196429 | 104790000 |
| 1 | 2002-05-24 | 1.214286 | 1.225000 | 1.197143 | 1.210000 | 1.210000 | 11104800 |
| 2 | 2002-05-28 | 1.213571 | 1.232143 | 1.157143 | 1.157143 | 1.157143 | 6609400 |
| 3 | 2002-05-29 | 1.164286 | 1.164286 | 1.085714 | 1.103571 | 1.103571 | 6757800 |
| 4 | 2002-05-30 | 1.107857 | 1.107857 | 1.071429 | 1.071429 | 1.071429 | 10154200 |
sns.set(rc={'figure.figsize':(10,5)})
df['Date'] = pd.to_datetime(df['Date'])
df = df.set_index('Date')
df.head()
| Open | High | Low | Close | Adj Close | Volume | |
|---|---|---|---|---|---|---|
| Date | ||||||
| 2002-05-23 | 1.156429 | 1.242857 | 1.145714 | 1.196429 | 1.196429 | 104790000 |
| 2002-05-24 | 1.214286 | 1.225000 | 1.197143 | 1.210000 | 1.210000 | 11104800 |
| 2002-05-28 | 1.213571 | 1.232143 | 1.157143 | 1.157143 | 1.157143 | 6609400 |
| 2002-05-29 | 1.164286 | 1.164286 | 1.085714 | 1.103571 | 1.103571 | 6757800 |
| 2002-05-30 | 1.107857 | 1.107857 | 1.071429 | 1.071429 | 1.071429 | 10154200 |
sns.lineplot(x = 'Date', y = 'Volume', data = df, label = "Volume")
plt.title("Volume of Stock vs Time ")
plt.show()
sns.lineplot(x = df.index, y = df['Volume'], label = 'Volume')
plt.title('Volume of stock versus time')
plt.show()
df.head()
| Open | High | Low | Close | Adj Close | Volume | |
|---|---|---|---|---|---|---|
| Date | ||||||
| 2002-05-23 | 1.156429 | 1.242857 | 1.145714 | 1.196429 | 1.196429 | 104790000 |
| 2002-05-24 | 1.214286 | 1.225000 | 1.197143 | 1.210000 | 1.210000 | 11104800 |
| 2002-05-28 | 1.213571 | 1.232143 | 1.157143 | 1.157143 | 1.157143 | 6609400 |
| 2002-05-29 | 1.164286 | 1.164286 | 1.085714 | 1.103571 | 1.103571 | 6757800 |
| 2002-05-30 | 1.107857 | 1.107857 | 1.071429 | 1.071429 | 1.071429 | 10154200 |
df.plot(y= ['High', 'Close', 'Open'], title = "netflix stock price")
plt.show()
import plotly.graph_objects as go
y1 = df['High']
y2 = df['Close']
y3 = df['Open']
fig = go.Figure()
fig.add_trace(go.Scatter(x = df.index, y = y1, name = 'High'))
fig.add_trace(go.Scatter(x = df.index, y = y2, name = 'close'))
fig.add_trace(go.Scatter(x = df.index, y = y3, name = 'Open'))
fig.update_layout(title = "High, Close, Open vs Date", xaxis_title = "Date", yaxis_title = "High, Close, Open" )
fig.show()
df.head()
| Open | High | Low | Close | Adj Close | Volume | |
|---|---|---|---|---|---|---|
| Date | ||||||
| 2002-05-23 | 1.156429 | 1.242857 | 1.145714 | 1.196429 | 1.196429 | 104790000 |
| 2002-05-24 | 1.214286 | 1.225000 | 1.197143 | 1.210000 | 1.210000 | 11104800 |
| 2002-05-28 | 1.213571 | 1.232143 | 1.157143 | 1.157143 | 1.157143 | 6609400 |
| 2002-05-29 | 1.164286 | 1.164286 | 1.085714 | 1.103571 | 1.103571 | 6757800 |
| 2002-05-30 | 1.107857 | 1.107857 | 1.071429 | 1.071429 | 1.071429 | 10154200 |
fig,(ax1,ax2,ax3) = plt.subplots(3, figsize = (15,10))
fig,(ax1,ax2,ax3) = plt.subplots(3, figsize = (15,10))
df.groupby(df.index.day).mean().plot(y = 'Volume', ax = ax1, xlabel = 'Day')
<Axes: xlabel='Day'>
fig, (ax1,ax2,ax3) = plt.subplots(3,figsize = (15,10))
df.groupby(df.index.month).mean().plot(y = 'Volume', ax = ax2, xlabel = 'month')
<Axes: xlabel='month'>
fig, (ax1,ax2,ax3) = plt.subplots(3,figsize = (15,10))
df.groupby(df.index.year).mean().plot(y = 'Volume', ax = ax3, xlabel = 'month')
<Axes: xlabel='month'>
fig, (ax1,ax2,ax3) = plt.subplots(3,figsize = (15,10))
df.groupby(df.index.day).mean().plot(y = 'Volume', ax = ax1, xlabel = 'Day')
df.groupby(df.index.month).mean().plot(y = 'Volume', ax = ax2, xlabel = 'Month')
df.groupby(df.index.year).mean().plot(y = 'Volume', ax = ax3, xlabel = 'Year')
<Axes: xlabel='Year'>
df
| Open | High | Low | Close | Adj Close | Volume | |
|---|---|---|---|---|---|---|
| Date | ||||||
| 2002-05-23 | 1.156429 | 1.242857 | 1.145714 | 1.196429 | 1.196429 | 104790000 |
| 2002-05-24 | 1.214286 | 1.225000 | 1.197143 | 1.210000 | 1.210000 | 11104800 |
| 2002-05-28 | 1.213571 | 1.232143 | 1.157143 | 1.157143 | 1.157143 | 6609400 |
| 2002-05-29 | 1.164286 | 1.164286 | 1.085714 | 1.103571 | 1.103571 | 6757800 |
| 2002-05-30 | 1.107857 | 1.107857 | 1.071429 | 1.071429 | 1.071429 | 10154200 |
| ... | ... | ... | ... | ... | ... | ... |
| 2022-05-27 | 193.190002 | 195.250000 | 190.369995 | 195.190002 | 195.190002 | 8586000 |
| 2022-05-31 | 196.179993 | 199.949997 | 190.800003 | 197.440002 | 197.440002 | 11398500 |
| 2022-06-01 | 198.699997 | 202.740005 | 191.660004 | 192.910004 | 192.910004 | 8416200 |
| 2022-06-02 | 192.020004 | 205.470001 | 191.720001 | 205.089996 | 205.089996 | 9623100 |
| 2022-06-03 | 200.139999 | 202.949997 | 198.050003 | 198.979996 | 198.979996 | 7181700 |
5044 rows × 6 columns
a = df.sort_values(by = 'High', ascending = False).head()
a['High']
Date 2021-11-17 700.989990 2021-11-19 694.159973 2021-11-18 691.739990 2021-10-29 690.969971 2021-11-01 689.969971 Name: High, dtype: float64
b = df.sort_values(by = 'Low', ascending = True).head(5)
b['Low']
Date 2002-10-10 0.346429 2002-10-09 0.347143 2002-10-07 0.382143 2002-10-08 0.390714 2002-10-16 0.442857 Name: Low, dtype: float64
fig, axes = plt.subplots(nrows = 1, ncols = 2, sharex = True, figsize = (12,5))
fig.suptitle('High and Low Stock Per Period of time ', fontsize = 18)
sns.lineplot(ax = axes[0], y = df['High'], x = df.index,color = 'green')
sns.lineplot(ax = axes[1], y = df['Low'], x = df.index, color = 'red')
<Axes: xlabel='Date', ylabel='Low'>